#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <fstream>

using namespace std;

typedef pair<string, int> siPair;

// 仿函数，函数对象
struct Dump {
    Dump(int i):n(i) {}

    void operator()(siPair e) {
        if (e.second >= n)
            cout << e.first << " " << e.second << endl;
    }

    int n;
};


void Disp(siPair e) {
    cout << e.first << " " << e.second << endl;
}

struct Comp {

    bool operator()(siPair e1, siPair e2) {
        return e1.second > e2.second;
    }

};

int main() {
    map<string, int> vote;
    ifstream in("in.txt");

    string name;
    while (in >> name) {
        /*
        map<string, int>::iterator it = vote.find(name);
        if (it != vote.end()) {
            ++vote[name];
        } else {
            vote.insert(make_pair(name, 1));
        }
        */

        ++vote[name];
    }

    //for_each(vote.begin(), vote.end(), Dump());
    vector<siPair> vec(vote.begin(), vote.end());
    sort(vec.begin(), vec.end(), Comp());
    for_each(vec.begin(), vec.end(), Dump(2));

    return 0;
}
























